package graph

func findSmallestSetOfVertices(n int, edges [][]int) []int {

	inCount := map[int]int{}

	for _, v := range edges {
		if _, ok := inCount[v[1]]; !ok {
			inCount[v[1]] = 1
		} else {
			inCount[v[1]]++
		}
	}

	res := []int{}
	for i := 0; i < n; i++ {
		if _, ok := inCount[i]; ok {
			continue
		}
		res = append(res, i)
	}

	return res

}
